#include <jni.h>
#include <string>

class JniHelper
{
public:
	static std::string jstringTostring(JNIEnv* env, jstring jstr);
	static jstring stoJstring(JNIEnv* env, const char* str);
	static jbyteArray bytesToJbyteArray(JNIEnv* env, unsigned char* data, int size);
	static void jbyteArrayToBytes(JNIEnv* env, jbyteArray byteArray, unsigned char* data, int size);
};

class JniField
{
public:
	JniField(JNIEnv* env, const char* classname, jobject obj, const char* fieldname, const char* fieldsig);
	bool isvalid();
public:
	jint getInt();
	jobject getObject();
	jchar getChar();
	jshort getShort();
	jboolean getBoolean();

private:
	jfieldID m_fid;
	JNIEnv* m_env;
	jobject m_obj;
};
